﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <Style x:Key="ComboBoxEditableTextBox"
           TargetType="{x:Type TextBox}">
    <Setter Property="OverridesDefaultStyle"
                Value="true"/>
    <Setter Property="AllowDrop"
                Value="true"/>
    <Setter Property="MinWidth"
                Value="0"/>
    <Setter Property="MinHeight"
                Value="0"/>
    <Setter Property="FocusVisualStyle"
                Value="{x:Null}"/>
    <Setter Property="ScrollViewer.PanningMode"
                Value="VerticalFirst"/>
    <Setter Property="Stylus.IsFlicksEnabled"
                Value="False"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TextBox}">
          <ScrollViewer x:Name="PART_ContentHost"
                                  Focusable="false"
                                  HorizontalScrollBarVisibility="Hidden"
                                  VerticalScrollBarVisibility="Hidden"
                                  Background="Transparent"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>


  <SolidColorBrush x:Key="ToolBarLightFill"
                     Color="#F7F7FF"/>
  <SolidColorBrush x:Key="ToolBarMediumFill"
                     Color="#D6DBE7"/>
  <SolidColorBrush x:Key="ToolBarDarkFill"
                     Color="#99CCFF"/>
  <SolidColorBrush x:Key="ToolBarDisabledFill"
                     Color="#F7F7F7"/>
  <SolidColorBrush x:Key="ToolBarDisabledBorder"
                     Color="#B5B2B5"/>
  
  <!--SolidColorBrush x:Key="ToolBarSeparatorFill"
                     Color="#C6C7C6"/-->
  <SolidColorBrush x:Key="ToolBarSeparatorFill"
                     Color="#8591A2"/>
  
  <!--SolidColorBrush x:Key="ToolBarButtonHover"
                     Color="#C2E0FF"/-->
  <LinearGradientBrush x:Key="ToolBarButtonHover"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#FFFCF2"
                          Offset="0"/>
      <GradientStop Color="#FFF3CF"
                          Offset="0.5"/>
      <GradientStop Color="#FFECB5"
                          Offset="0.5"/>
      <GradientStop Color="#FFECB5"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush>
  
  <!--SolidColorBrush x:Key="ToolBarButtonHoverBorder"
                     Color="#3399FF"/-->
  <SolidColorBrush x:Key="ToolBarButtonHoverBorder"
                     Color="#E5C365"/>
  
  <!--SolidColorBrush x:Key="ToolBarButtonChecked"
                     Color="#E6F0FA"/-->
  <SolidColorBrush x:Key="ToolBarButtonChecked"
                     Color="#FFEFBB"/>
  
  <!--SolidColorBrush x:Key="ToolBarButtonPressed"
                     Color="#99CCFF"/-->
  <SolidColorBrush x:Key="ToolBarButtonPressed"
                     Color="#FFE8A6"/>
  
  <!--SolidColorBrush x:Key="ToolBarButtonPressedBorder"
                     Color="#3399FF"/-->
  <SolidColorBrush x:Key="ToolBarButtonPressedBorder"
                     Color="#E5C365"/>
  
  <SolidColorBrush x:Key="ToolBarMenuBorder"
                     Color="#808080"/>
  <SolidColorBrush x:Key="ToolBarSubMenuBackground"
                     Color="#FDFDFD"/>
  <SolidColorBrush x:Key="ToolBarMenuCheckFill"
                     Color="#E6F0FA"/>
  <LinearGradientBrush x:Key="ToolBarOpenHeaderBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#FFFFFF"
                          Offset="0"/>
      <GradientStop Color="#FFFBFF"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush>
  
  <!--LinearGradientBrush x:Key="ToolBarTrayBackground"
                         StartPoint="0,0"
                         EndPoint="688,0"
                         MappingMode="Absolute">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#F4F4F4"
                          Offset="0"/>
      <GradientStop Color="#FDFDFD"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush-->
  <SolidColorBrush x:Key="ToolBarTrayBackground" Color="#9CAAC1"/>
  
  <!--LinearGradientBrush x:Key="ToolBarHorizontalBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#FFFFFF"
                          Offset="0"/>
      <GradientStop Color="#FFFBFF"
                          Offset="0.5"/>
      <GradientStop Color="#F7F7F7"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush-->
  <SolidColorBrush x:Key="ToolBarHorizontalBackground" Color="#BCC7D8"/>

  <!--LinearGradientBrush x:Key="ToolBarVerticalBackground"
                         StartPoint="0,0"
                         EndPoint="1,0">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#FFFFFF"
                          Offset="0"/>
      <GradientStop Color="#FFFBFF"
                          Offset="0.5"/>
      <GradientStop Color="#F7F7F7"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush-->
  <SolidColorBrush x:Key="ToolBarVerticalBackground" Color="#BCC7D8"/>
  
  <SolidColorBrush x:Key="ToolBarBorder" Color="#D5DCE8"/>

  <!--SolidColorBrush x:Key="ToolBarGripper"
                     Color="#C6C3C6"/-->
  <SolidColorBrush x:Key="ToolBarGripper"
                     Color="#61738C"/>
  
  <!--LinearGradientBrush x:Key="ToolBarToggleButtonHorizontalBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#ECECEC"
                          Offset="0"/>
      <GradientStop Color="#DDDDDD"
                          Offset="0.5"/>
      <GradientStop Color="#A0A0A0"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush-->
  <SolidColorBrush x:Key="ToolBarToggleButtonHorizontalBackground" Color="#D5DCE8"/>
  
  <!--LinearGradientBrush x:Key="ToolBarToggleButtonVerticalBackground"
                         StartPoint="0,0"
                         EndPoint="1,0">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#ECECEC"
                          Offset="0"/>
      <GradientStop Color="#DDDDDD"
                          Offset="0.5"/>
      <GradientStop Color="#A0A0A0"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush-->
  <SolidColorBrush x:Key="ToolBarToggleButtonVerticalBackground" Color="#D5DCE8"/>



  <Geometry x:Key="ToolBarCheckmark">M 0,2.5 L 2.5,5 L 7,0.5</Geometry>

  <Style x:Key="ToolBarMainPanelBorderStyle" TargetType="{x:Type Border}">
    <Style.Triggers>
      <DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
        <Setter Property="CornerRadius" Value="0,0,0,0" />
      </DataTrigger>
    </Style.Triggers>
    <Setter Property="Margin" Value="0,0,11,0" />
    <Setter Property="CornerRadius" Value="3,3,3,3" />
  </Style>

  <Style x:Key="{x:Static ToolBar.SeparatorStyleKey}"
           TargetType="{x:Type Separator}">
    <Setter Property="Background"
                Value="{StaticResource ToolBarSeparatorFill}"/>
    <Setter Property="MinWidth"
                Value="1"/>
    <Setter Property="MinHeight"
                Value="1"/>
    <Setter Property="Margin"
                Value="2,2,2,2"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Separator}">
          <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="true"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="{x:Static ToolBar.ButtonStyleKey}"
           TargetType="{x:Type Button}">
    <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    <Setter Property="Padding"
                Value="2"/>
    <Setter Property="BorderThickness"
                Value="1"/>
    <Setter Property="Background"
                Value="Transparent"/>
    <Setter Property="BorderBrush"
                Value="Transparent"/>
    <Setter Property="HorizontalAlignment"
                Value="Center"/>
    <Setter Property="VerticalAlignment"
                Value="Center"/>
    <Setter Property="HorizontalContentAlignment"
                Value="Center"/>
    <Setter Property="VerticalContentAlignment"
                Value="Center"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Button}">
          <Border Name="Bd"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="true">
            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"
                                 Value="true">
              <Setter TargetName="Bd"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
              <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused"
                                 Value="true">
              <Setter TargetName="Bd"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
              <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsPressed"
                                 Value="true">
              <Setter TargetName="Bd"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonPressedBorder}"/>
              <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonPressed}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                                 Value="false">
              <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="{x:Static ToolBar.ToggleButtonStyleKey}"
           TargetType="{x:Type ToggleButton}">
    <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    <Setter Property="Padding"
                Value="2"/>
    <Setter Property="BorderThickness"
                Value="1"/>
    <Setter Property="Background"
                Value="Transparent"/>
    <Setter Property="BorderBrush"
                Value="Transparent"/>
    <Setter Property="HorizontalAlignment"
                Value="Center"/>
    <Setter Property="VerticalAlignment"
                Value="Center"/>
    <Setter Property="HorizontalContentAlignment"
                Value="Center"/>
    <Setter Property="VerticalContentAlignment"
                Value="Center"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="true">
            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsChecked"
                                 Value="true">
              <Setter Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
              <Setter Property="Background"
                                    Value="{StaticResource ToolBarButtonChecked}"/>
            </Trigger>
            <Trigger Property="IsMouseOver"
                                 Value="true">
              <Setter Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
              <Setter Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused"
                                 Value="true">
              <Setter Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
              <Setter Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver"
                                           Value="true"/>
                <Condition Property="IsChecked"
                                           Value="true"/>
              </MultiTrigger.Conditions>
              <Setter Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonPressedBorder}"/>
              <Setter Property="Background"
                                    Value="{StaticResource ToolBarButtonPressed}"/>
            </MultiTrigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsKeyboardFocused"
                                           Value="true"/>
                <Condition Property="IsChecked"
                                           Value="true"/>
              </MultiTrigger.Conditions>
              <Setter Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonPressedBorder}"/>
              <Setter Property="Background"
                                    Value="{StaticResource ToolBarButtonPressed}"/>
            </MultiTrigger>
            <Trigger Property="IsPressed"
                                 Value="true">
              <Setter Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonPressedBorder}"/>
              <Setter Property="Background"
                                    Value="{StaticResource ToolBarButtonPressed}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                                 Value="false">
              <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="{x:Static ToolBar.CheckBoxStyleKey}"
           BasedOn="{StaticResource {x:Static ToolBar.ToggleButtonStyleKey}}"
           TargetType="{x:Type CheckBox}"/>
  <Style x:Key="{x:Static ToolBar.RadioButtonStyleKey}"
           BasedOn="{StaticResource {x:Static ToolBar.ToggleButtonStyleKey}}"
           TargetType="{x:Type RadioButton}"/>


  <Style x:Key="ToolBarComboBoxTransparentButtonStyle"
           TargetType="{x:Type ToggleButton}">
    <Setter Property="MinWidth"
                Value="0"/>
    <Setter Property="MinHeight"
                Value="0"/>
    <Setter Property="Width"
                Value="Auto"/>
    <!--Setter Property="Background"
                Value="Transparent"/-->
    <Setter Property="Background"
                Value="White"/>
    <Setter Property="Focusable"
                Value="false"/>
    <Setter Property="ClickMode"
                Value="Press"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Grid Background="Transparent">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
              <ColumnDefinition Width="Auto"
                                              SharedSizeGroup="ComboBoxButton"/>
            </Grid.ColumnDefinitions>
            <Border x:Name="Chrome"
                                Grid.Column="1"
                                Width="13"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="true">
              <Path x:Name="ArrowDownPath"
                                  Data="M 2.5 0 L 8.5 0 L 5.5 3 Z"
                                  Fill="black"
                                  VerticalAlignment="Center"/>
            </Border>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled"
                                 Value="false">
              <Setter TargetName="Chrome"
                                    Property="BorderBrush"
                                    Value="{x:Null}"/>
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver"
                                           Value="true"/>
                <Condition Property="IsChecked"
                                           Value="false"/>
              </MultiTrigger.Conditions>
              <Setter TargetName="Chrome"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
            </MultiTrigger>
            <Trigger Property="IsChecked"
                                 Value="true">
              <Setter TargetName="Chrome"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonPressedBorder}"/>
            </Trigger>
            <Trigger Property="IsPressed"
                                 Value="true">
              <Setter TargetName="Chrome"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonPressed}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                                 Value="false">
              <Setter TargetName="ArrowDownPath"
                                    Property="Fill"
                                    Value="{StaticResource ToolBarDisabledBorder}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="{x:Static ToolBar.ComboBoxStyleKey}"
           TargetType="{x:Type ComboBox}">
    <Setter Property="FocusVisualStyle"
                Value="{x:Null}"/>
    <!--Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
    <Setter Property="Background"
                Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
    <Setter Property="BorderBrush"
                Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/-->
    <Setter Property="Foreground"
                Value="Black"/>
    <Setter Property="Background"
                Value="White"/>
    <Setter Property="BorderBrush"
                Value="{StaticResource ToolBarSeparatorFill}"/>
    <Setter Property="BorderThickness"
                Value="1"/>
    <Setter Property="Margin"
                Value="1,0"/>
    <Setter Property="Padding"
                Value="0"/>
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
                Value="Auto"/>
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
                Value="Auto"/>
    <Setter Property="ScrollViewer.CanContentScroll"
                Value="true"/>
    <Setter Property="ScrollViewer.PanningMode"
                Value="Both"/>
    <Setter Property="Stylus.IsFlicksEnabled"
                Value="False"/>
    <Setter Property="HorizontalAlignment"
                Value="Center"/>
    <Setter Property="VerticalAlignment"
                Value="Center"/>
    <Setter Property="MinHeight"
                Value="18"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ComboBox}">
          <Grid SnapsToDevicePixels="true">
            <Grid Grid.IsSharedSizeScope="true">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"
                                                  SharedSizeGroup="ComboBoxButton"/>
              </Grid.ColumnDefinitions>
              <Border Name="Background"
                                    Background="{TemplateBinding Background}"/>
              <Border Name="SelectedContentBorder"
                                    Margin="2,2,1,2">
                <ContentPresenter x:Name="ContentSite"
                                                  Content="{TemplateBinding SelectionBoxItem}"
                                                  ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                                  ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                                  Margin="{TemplateBinding Padding}"
                                                  VerticalAlignment="Center"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
              </Border>
              <Border Name="Border"
                                    Grid.ColumnSpan="2"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{TemplateBinding BorderBrush}"/>
              <ToggleButton BorderBrush="white"
                            Margin="0,1,1,1"
                                          BorderThickness="1"
                                          x:Name="DropDownButton"
                                          Grid.ColumnSpan="2"
                                          Style="{StaticResource ToolBarComboBoxTransparentButtonStyle}"
                                          IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"/>
              <TextBox Padding="{TemplateBinding Padding}"
                                     Margin="1,1,0,1"
                                     MinHeight="18"
                                     x:Name="PART_EditableTextBox"
                                     Style="{StaticResource ComboBoxEditableTextBox}"
                                     Visibility="Collapsed"
                                     IsReadOnly="{Binding Path=IsReadOnly,RelativeSource={RelativeSource TemplatedParent}}"
                                     VerticalAlignment="Center"/>
            </Grid>
            <Popup Name="PART_Popup"
                               AllowsTransparency="true"
                               Placement="Bottom"
                               IsOpen="{Binding Path=IsDropDownOpen,RelativeSource={RelativeSource TemplatedParent}}"
                               Focusable="false"
                               PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
              <!--theme:SystemDropShadowChrome Name="Shdw"
                                                          Color="Transparent" 
                                                          MinWidth="{TemplateBinding ActualWidth}"
                                                          MaxHeight="{TemplateBinding MaxDropDownHeight}"-->
                <Border x:Name="DropDownBorder"
                                        Background="{TemplateBinding Background}"
                                        BorderThickness="1"
                                        BorderBrush="{StaticResource ToolBarMenuBorder}">
                  <ScrollViewer Name="DropDownScrollViewer">
                    <Grid RenderOptions.ClearTypeHint="Enabled">
                      <Canvas Height="0" Width="0" HorizontalAlignment="Left" VerticalAlignment="Top">
                        <Rectangle
                                                Name="OpaqueRect"
                                                Height="{Binding ElementName=DropDownBorder,Path=ActualHeight}" 
                                                Width="{Binding ElementName=DropDownBorder,Path=ActualWidth}" 
                                                Fill="{Binding ElementName=DropDownBorder,Path=Background}" />
                      </Canvas>
                      <ItemsPresenter Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained"/>
                    </Grid>
                  </ScrollViewer>
                </Border>
              <!--/theme:SystemDropShadowChrome-->
            </Popup>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled"
                                 Value="false">
              <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
              <Setter TargetName="Background"
                                    Property="Background"
                                    Value="{StaticResource ToolBarDisabledFill}"/>
              <Setter TargetName="Background"
                                    Property="Grid.ColumnSpan"
                                    Value="2"/>
              <Setter TargetName="Border"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarDisabledBorder}"/>
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsKeyboardFocusWithin"
                                           Value="true"/>
                <Condition Property="IsDropDownOpen"
                                           Value="false"/>
                <Condition Property="IsEditable"
                                           Value="false"/>
              </MultiTrigger.Conditions>
              <Setter TargetName="SelectedContentBorder"
                                    Property="Background"
                                    Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
            </MultiTrigger>
            <Trigger Property="IsEditable"
                                 Value="true">
              <Setter TargetName="DropDownButton"
                                    Property="Background"
                                    Value="{x:Null}"/>
              <Setter TargetName="ContentSite"
                                    Property="Visibility"
                                    Value="Collapsed"/>
              <Setter TargetName="PART_EditableTextBox"
                                    Property="Visibility"
                                    Value="Visible"/>
            </Trigger>
            <Trigger Property="IsMouseOver"
                                 Value="true">
              <Setter TargetName="DropDownButton"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
              <Setter TargetName="DropDownButton"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
              <Setter TargetName="Border"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin"
                                 Value="true">
              <Setter TargetName="DropDownButton"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
              <Setter TargetName="DropDownButton"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
              <Setter TargetName="Border"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
            </Trigger>
            <Trigger SourceName="PART_Popup"
                                 Property="Popup.HasDropShadow"
                                 Value="true">
              <!--Setter TargetName="Shdw"
                                    Property="Margin"
                                    Value="0,0,5,5"/>
              <Setter TargetName="Shdw"
                                    Property="SnapsToDevicePixels"
                                    Value="true"/>
              <Setter TargetName="Shdw"
                                    Property="Color"
                                    Value="#71000000"/-->
            </Trigger>
            <Trigger Property="HasItems"
                                 Value="false">
              <Setter TargetName="DropDownBorder"
                                    Property="MinHeight"
                                    Value="95"/>
            </Trigger>
            <Trigger Property="IsGrouping"
                                 Value="true">
              <Setter Property="ScrollViewer.CanContentScroll"
                                    Value="false"/>
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsKeyboardFocusWithin"
                                           Value="true"/>
                <Condition Property="IsDropDownOpen"
                                           Value="false"/>
                <Condition Property="IsEditable"
                                           Value="false"/>
              </MultiTrigger.Conditions>
              <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
            </MultiTrigger>
            <Trigger Property="IsEditable"
                                 Value="true">
              <Setter Property="Padding"
                                    Value="2"/>
              <Setter Property="IsTabStop"
                                    Value="false"/>
            </Trigger>
            <Trigger SourceName="DropDownScrollViewer"
                                 Property="ScrollViewer.CanContentScroll"
                                 Value="false" >
              <Setter TargetName="OpaqueRect" 
                                    Property="Canvas.Top" 
                                    Value="{Binding ElementName=DropDownScrollViewer, Path=VerticalOffset}" />
              <Setter TargetName="OpaqueRect" 
                                    Property="Canvas.Left" 
                                    Value="{Binding ElementName=DropDownScrollViewer, Path=HorizontalOffset}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>


  <Style x:Key="{x:Static ToolBar.TextBoxStyleKey}"
           TargetType="{x:Type TextBox}">
    <Setter Property="FocusVisualStyle"
                Value="{x:Null}"/>
    <!--Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
    <Setter Property="Background"
                Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
    <Setter Property="BorderBrush"
                Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/-->
    <Setter Property="Foreground"
                Value="Black"/>
    <Setter Property="Background"
                Value="White"/>
    <Setter Property="BorderBrush"
                Value="{StaticResource ToolBarSeparatorFill}"/>
    <Setter Property="BorderThickness"
                Value="1"/>
    <Setter Property="Margin"
                Value="1,0"/>
    <Setter Property="Padding"
                Value="2"/>
    <Setter Property="HorizontalAlignment"
                Value="Center"/>
    <Setter Property="VerticalAlignment"
                Value="Center"/>
    <Setter Property="MinHeight"
                Value="18"/>
    <Setter Property="ScrollViewer.PanningMode"
                Value="VerticalFirst"/>
    <Setter Property="Stylus.IsFlicksEnabled"
                Value="False"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TextBox}">
          <Border Name="Border"
                            Background="{TemplateBinding Background}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            SnapsToDevicePixels="true">
            <ScrollViewer x:Name="PART_ContentHost"
                                      VerticalAlignment="Center"
                                      MinHeight="18"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled"
                                 Value="false">
              <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
              <Setter TargetName="Border"
                                    Property="Background"
                                    Value="{StaticResource ToolBarDisabledFill}"/>
              <Setter TargetName="Border"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarDisabledBorder}"/>
            </Trigger>
            <Trigger Property="IsMouseOver"
                                 Value="true">
              <Setter TargetName="Border"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin"
                                 Value="true">
              <Setter TargetName="Border"
                                    Property="BorderBrush"
                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>


  <Style x:Key="{x:Static ToolBar.MenuStyleKey}"
           TargetType="{x:Type Menu}">
    <Setter Property="FontFamily"
                Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}"/>
    <Setter Property="FontSize"
                Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}"/>
    <Setter Property="FontStyle"
                Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}"/>
    <Setter Property="FontWeight"
                Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}"/>
    <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
    <Setter Property="VerticalContentAlignment"
                Value="Center"/>
    <Setter Property="KeyboardNavigation.TabNavigation"
                Value="Continue"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Menu}">
          <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="true">
            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Resources>
      <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
        <Setter Property="OverridesDefaultStyle" 
                        Value="true" />
        <Setter Property="Background" 
                        Value="{StaticResource ToolBarSeparatorFill}" />
        <Setter Property="Height" Value="1" />
        <Setter Property="Margin" Value="0,1,0,0" />
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type Separator}">
              <Grid SnapsToDevicePixels="true">
                <Grid.ColumnDefinitions>
                  <ColumnDefinition MinWidth="24" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup" />
                  <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Border Grid.Column="1" Margin="8,0,0,0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
              </Grid>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>
      <Style x:Key="{x:Type MenuItem}"
                   TargetType="{x:Type MenuItem}">
        <Setter Property="OverridesDefaultStyle" 
                        Value="true" />
        <Setter Property="HorizontalContentAlignment"
                        Value="{Binding Path=HorizontalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment"
                        Value="{Binding Path=VerticalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Background"
                        Value="Transparent"/>
        <Setter Property="Foreground"
                        Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
        <Setter Property="BorderThickness"
                        Value="1"/>
        <Setter Property="Margin"
                        Value="0,1,0,0"/>
        <Setter Property="Padding"
                        Value="8,3,8,3"/>
        <Setter Property="DockPanel.Dock"
                        Value="Top"/>
        <Setter Property="ScrollViewer.PanningMode"
                        Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled"
                        Value="False"/>
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type MenuItem}">
              <Grid Background="Transparent"
                                  SnapsToDevicePixels="true">
                <Grid.ColumnDefinitions>
                  <ColumnDefinition MinWidth="24"
                                                      Width="Auto"
                                                      SharedSizeGroup="MenuItemIconColumnGroup"/>
                  <ColumnDefinition Width="*"/>
                  <ColumnDefinition Width="Auto"
                                                      SharedSizeGroup="MenuItemIGTColumnGroup"/>
                  <ColumnDefinition Width="14"/>
                </Grid.ColumnDefinitions>
                <Border Name="Border"
                                        Background="{TemplateBinding Background}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        BorderBrush="{TemplateBinding BorderBrush}"
                                        Grid.ColumnSpan="4"
                                        Margin="1,0"/>
                <ContentPresenter x:Name="Icon"
                                                  Margin="0"
                                                  VerticalAlignment="Center"
                                                  ContentSource="Icon"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                <Border Name="GlyphPanel"
                                        Margin="0,1"
                                        Width="20"
                                        Height="20"
                                        Visibility="Hidden"
                                        BorderBrush="{StaticResource ToolBarButtonHoverBorder}"
                                        Background="{StaticResource ToolBarMenuCheckFill}"
                                        BorderThickness="1">
                  <Path VerticalAlignment="Center"
                                          HorizontalAlignment="Center"
                                          FlowDirection="LeftToRight"
                                          Stroke="{TemplateBinding Foreground}"
                                          StrokeThickness="1.2"
                                          Data="{StaticResource ToolBarCheckmark}"/>
                </Border>

                <ContentPresenter Grid.Column="1"
                                                  ContentSource="Header"
                                                  Margin="{TemplateBinding Padding}"
                                                  RecognizesAccessKey="True"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                <TextBlock Grid.Column="2"
                                           Text="{TemplateBinding InputGestureText}"
                                           Margin="4,3,2,3"
                                           HorizontalAlignment="Right"/>
              </Grid>
              <ControlTemplate.Triggers>
                <Trigger Property="Icon"
                                         Value="{x:Null}">
                  <Setter TargetName="Icon"
                                            Property="Visibility"
                                            Value="Collapsed"/>
                </Trigger>
                <Trigger Property="IsChecked"
                                         Value="true">
                  <Setter TargetName="GlyphPanel"
                                            Property="Visibility"
                                            Value="Visible"/>
                  <Setter TargetName="Icon"
                                            Property="Visibility"
                                            Value="Collapsed"/>
                </Trigger>
                <Trigger Property="IsHighlighted"
                                         Value="true">
                  <Setter TargetName="Border"
                                            Property="BorderBrush"
                                            Value="{StaticResource ToolBarButtonHoverBorder}"/>
                  <Setter TargetName="Border"
                                            Property="Background"
                                            Value="{StaticResource ToolBarButtonHover}"/>
                  <Setter TargetName="GlyphPanel"
                                            Property="BorderBrush"
                                            Value="{StaticResource ToolBarButtonPressedBorder}"/>
                  <Setter TargetName="GlyphPanel"
                                            Property="Background"
                                            Value="{StaticResource ToolBarDarkFill}"/>
                </Trigger>
                <Trigger Property="IsEnabled"
                                         Value="false">
                  <Setter Property="Foreground"
                                            Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                </Trigger>
              </ControlTemplate.Triggers>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
        <Style.Triggers>
          <Trigger Property="Role"
                             Value="TopLevelHeader">
            <Setter Property="Padding"
                                Value="6,2,7,2"/>
            <Setter Property="Grid.IsSharedSizeScope"
                                Value="true"/>
            <Setter Property="Template">
              <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                  <Border Name="Border"
                                            Background="{TemplateBinding Background}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="1"
                                            SnapsToDevicePixels="true">
                    <DockPanel Name="Header">
                      <ContentPresenter x:Name="Icon"
                                                              Margin="4,0,6,0"
                                                              VerticalAlignment="Center"
                                                              ContentSource="Icon"
                                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                      <Path x:Name="GlyphPanel"
                                                  Margin="4,0,6,0"
                                                  Visibility="Collapsed"
                                                  VerticalAlignment="Center"
                                                  FlowDirection="LeftToRight"
                                                  Stroke="{TemplateBinding Foreground}"
                                                  StrokeThickness="1.2"
                                                  Data="{StaticResource ToolBarCheckmark}"/>
                      <ContentPresenter ContentSource="Header"
                                                              Margin="{TemplateBinding Padding}"
                                                              RecognizesAccessKey="True"
                                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                      <Popup x:Name="PART_Popup"
                                                   Placement="Bottom"
                                                   HorizontalOffset="-1"
                                                   IsOpen="{Binding Path=IsSubmenuOpen,RelativeSource={RelativeSource TemplatedParent}}"
                                                   Focusable="false"
                                                   PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
                                                   AllowsTransparency="true">
                        <!--theme:SystemDropShadowChrome Name="Shdw"
                                                                              Color="Transparent"-->
                          <Border Name="SubMenuBorder" Background="{StaticResource ToolBarSubMenuBackground}"
                                                            BorderBrush="{StaticResource ToolBarMenuBorder}"
                                                            BorderThickness="1">
                            <Grid Grid.IsSharedSizeScope="true">
                              <Grid.ColumnDefinitions>
                                <ColumnDefinition MinWidth="24"
                                                                                  Width="Auto"
                                                                                  SharedSizeGroup="MenuItemIconColumnGroup"/>
                                <ColumnDefinition Width="*"/>
                              </Grid.ColumnDefinitions>
                              <Rectangle Fill="{StaticResource ToolBarVerticalBackground}"
                                                                       Margin="0,1"/>
                              <Rectangle Fill="{StaticResource ToolBarSubMenuBackground}"
                                                                       Grid.ColumnSpan="2"
                                                                       Margin="0,-1,0,0"
                                                                       VerticalAlignment="Top"
                                                                       HorizontalAlignment="Left"
                                                                       Height="1"
                                                                       Width="{Binding ElementName=Header, Path=ActualWidth}" />
                              <ScrollViewer Name="SubMenuScrollViewer" CanContentScroll="true"
                                                                          Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}"
                                                                          Grid.ColumnSpan="2">
                                <Grid RenderOptions.ClearTypeHint="Enabled">
                                  <Canvas Height="0" Width="0" HorizontalAlignment="Left" VerticalAlignment="Top">
                                    <Rectangle
                                                                        Height="{Binding ElementName=SubMenuBorder,Path=ActualHeight}" 
                                                                        Width="{Binding ElementName=SubMenuBorder,Path=ActualWidth}" 
                                                                        Fill="{Binding ElementName=SubMenuBorder,Path=Background}" />
                                  </Canvas>
                                  <ItemsPresenter Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle"
                                                                                KeyboardNavigation.TabNavigation="Cycle"
                                                                                Margin="0,0,0,1"
                                                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                </Grid>
                              </ScrollViewer>
                            </Grid>
                          </Border>
                        <!--/theme:SystemDropShadowChrome-->
                      </Popup>
                    </DockPanel>
                  </Border>
                  <ControlTemplate.Triggers>
                    <Trigger Property="IsSuspendingPopupAnimation"
                                                 Value="true">
                      <Setter TargetName="PART_Popup"
                                                    Property="PopupAnimation"
                                                    Value="None"/>
                    </Trigger>
                    <Trigger Property="Icon"
                                                 Value="{x:Null}">
                      <Setter TargetName="Icon"
                                                    Property="Visibility"
                                                    Value="Collapsed"/>
                    </Trigger>
                    <Trigger Property="IsChecked"
                                                 Value="true">
                      <Setter TargetName="GlyphPanel"
                                                    Property="Visibility"
                                                    Value="Visible"/>
                      <Setter TargetName="Icon"
                                                    Property="Visibility"
                                                    Value="Collapsed"/>
                    </Trigger>
                    <Trigger Property="IsHighlighted"
                                                 Value="true">
                      <Setter TargetName="Border"
                                                    Property="BorderBrush"
                                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
                      <Setter TargetName="Border"
                                                    Property="Background"
                                                    Value="{StaticResource ToolBarButtonHover}"/>
                    </Trigger>
                    <Trigger Property="IsSubmenuOpen"
                                                 Value="true">
                      <Setter TargetName="Border"
                                                    Property="BorderBrush"
                                                    Value="{StaticResource ToolBarMenuBorder}"/>
                      <Setter TargetName="Border"
                                                    Property="Background"
                                                    Value="{StaticResource ToolBarOpenHeaderBackground}"/>
                    </Trigger>
                    <Trigger SourceName="PART_Popup"
                                                  Property="Popup.HasDropShadow"
                                                  Value="true">
                      <!--Setter TargetName="Shdw"
                                                     Property="Margin"
                                                     Value="0,0,5,5"/>
                      <Setter TargetName="Shdw"
                                                     Property="SnapsToDevicePixels"
                                                     Value="true"/>
                      <Setter TargetName="Shdw"
                                                     Property="Color"
                                                     Value="#71000000"/-->
                    </Trigger>
                    <Trigger Property="IsEnabled"
                                                 Value="false">
                      <Setter Property="Foreground"
                                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                    </Trigger>
                  </ControlTemplate.Triggers>
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Trigger>
          <Trigger Property="Role"
                             Value="TopLevelItem">
            <Setter Property="Margin"
                                Value="0,1,0,1"/>
            <Setter Property="Padding"
                                Value="7,1,8,2"/>
            <Setter Property="Template">
              <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                  <Border Name="Border"
                                            Background="{TemplateBinding Background}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="1"
                                            SnapsToDevicePixels="true">
                    <DockPanel>
                      <ContentPresenter x:Name="Icon"
                                                              Margin="4,0,6,0"
                                                              VerticalAlignment="Center"
                                                              ContentSource="Icon"
                                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                      <Path x:Name="GlyphPanel"
                                                  Margin="4,0,6,0"
                                                  Visibility="Collapsed"
                                                  VerticalAlignment="Center"
                                                  FlowDirection="LeftToRight"
                                                  Stroke="{TemplateBinding Foreground}"
                                                  StrokeThickness="1.2"
                                                  Data="{StaticResource ToolBarCheckmark}"/>
                      <ContentPresenter ContentSource="Header"
                                                              Margin="{TemplateBinding Padding}"
                                                              RecognizesAccessKey="True"
                                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </DockPanel>
                  </Border>
                  <ControlTemplate.Triggers>
                    <Trigger Property="Icon"
                                                 Value="{x:Null}">
                      <Setter TargetName="Icon"
                                                    Property="Visibility"
                                                    Value="Collapsed"/>
                    </Trigger>
                    <Trigger Property="IsChecked"
                                                 Value="true">
                      <Setter TargetName="GlyphPanel"
                                                    Property="Visibility"
                                                    Value="Visible"/>
                      <Setter TargetName="Icon"
                                                    Property="Visibility"
                                                    Value="Collapsed"/>
                    </Trigger>
                    <Trigger Property="IsHighlighted"
                                                 Value="true">
                      <Setter TargetName="Border"
                                                    Property="BorderBrush"
                                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
                      <Setter TargetName="Border"
                                                    Property="Background"
                                                    Value="{StaticResource ToolBarButtonHover}"/>
                    </Trigger>
                    <Trigger Property="IsEnabled"
                                                 Value="false">
                      <Setter Property="Foreground"
                                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                    </Trigger>
                  </ControlTemplate.Triggers>
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Trigger>
          <Trigger Property="Role"
                             Value="SubmenuHeader">
            <Setter Property="DockPanel.Dock"
                                Value="Top"/>
            <Setter Property="Padding"
                                Value="8,3,8,3"/>
            <Setter Property="Grid.IsSharedSizeScope"
                                Value="true"/>
            <Setter Property="Template">
              <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                  <Grid Background="Transparent"
                                          SnapsToDevicePixels="true">
                    <Grid.ColumnDefinitions>
                      <ColumnDefinition MinWidth="24"
                                                              Width="Auto"
                                                              SharedSizeGroup="MenuItemIconColumnGroup"/>
                      <ColumnDefinition Width="*"/>
                      <ColumnDefinition Width="Auto"
                                                              SharedSizeGroup="MenuItemIGTColumnGroup"/>
                      <ColumnDefinition Width="14"/>
                    </Grid.ColumnDefinitions>
                    <Border Name="Border"
                                                Background="{TemplateBinding Background}"
                                                BorderThickness="{TemplateBinding BorderThickness}"
                                                BorderBrush="{TemplateBinding BorderBrush}"
                                                Grid.ColumnSpan="4"
                                                Margin="1,0"/>
                    <ContentPresenter x:Name="Icon"
                                                          Margin="3"
                                                          VerticalAlignment="Center"
                                                          ContentSource="Icon"
                                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    <Border Name="GlyphPanel"
                                                Margin="0,1"
                                                Width="20"
                                                Height="20"
                                                Visibility="Hidden"
                                                BorderBrush="{StaticResource ToolBarButtonHoverBorder}"
                                                Background="{StaticResource ToolBarMenuCheckFill}"
                                                BorderThickness="1">
                      <Path VerticalAlignment="Center"
                                                  HorizontalAlignment="Center"
                                                  FlowDirection="LeftToRight"
                                                  Stroke="{TemplateBinding Foreground}"
                                                  StrokeThickness="1.2"
                                                  Data="{StaticResource ToolBarCheckmark}"/>
                    </Border>
                    <ContentPresenter Grid.Column="1"
                                                          ContentSource="Header"
                                                          Margin="{TemplateBinding Padding}"
                                                          RecognizesAccessKey="True"
                                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    <Path Grid.Column="3"
                                              DockPanel.Dock="Right"
                                              VerticalAlignment="Center"
                                              Margin="4,0,6,0"
                                              Fill="{TemplateBinding Foreground}"
                                              Data="{StaticResource RightArrow}"/>
                    <Popup x:Name="PART_Popup"
                                               Placement="Right"
                                               IsOpen="{Binding Path=IsSubmenuOpen,RelativeSource={RelativeSource TemplatedParent}}"
                                               Focusable="false"
                                               PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
                                               AllowsTransparency="true">
                      <!--theme:SystemDropShadowChrome Name="Shdw"
                                                                          Color="Transparent"-->
                        <Border Name="SubMenuBorder" Background="{StaticResource ToolBarSubMenuBackground}"
                                                        BorderBrush="{StaticResource ToolBarMenuBorder}"
                                                        BorderThickness="1"
                                                        Grid.IsSharedSizeScope="true">
                          <Grid>
                            <Grid.ColumnDefinitions>
                              <ColumnDefinition MinWidth="24"
                                                                              Width="Auto"
                                                                              SharedSizeGroup="MenuItemIconColumnGroup"/>
                              <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Rectangle Fill="{StaticResource ToolBarVerticalBackground}"
                                                                   Margin="0,1"/>
                            <ScrollViewer Name="SubMenuScrollViewer" CanContentScroll="true"
                                                                      Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}"
                                                                      Grid.ColumnSpan="2">
                              <Grid RenderOptions.ClearTypeHint="Enabled">
                                <Canvas Height="0" Width="0" HorizontalAlignment="Left" VerticalAlignment="Top">
                                  <Rectangle
                                                                    Height="{Binding ElementName=SubMenuBorder,Path=ActualHeight}" 
                                                                    Width="{Binding ElementName=SubMenuBorder,Path=ActualWidth}" 
                                                                    Fill="{Binding ElementName=SubMenuBorder,Path=Background}" />
                                </Canvas>
                                <ItemsPresenter Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle"
                                                                            KeyboardNavigation.TabNavigation="Cycle"
                                                                            Margin="0,0,0,1"
                                                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                              </Grid>
                            </ScrollViewer>
                          </Grid>
                        </Border>
                      <!--/theme:SystemDropShadowChrome-->
                    </Popup>
                  </Grid>
                  <ControlTemplate.Triggers>
                    <Trigger Property="IsSuspendingPopupAnimation"
                                                 Value="true">
                      <Setter TargetName="PART_Popup"
                                                    Property="PopupAnimation"
                                                    Value="None"/>
                    </Trigger>
                    <Trigger Property="Icon"
                                                 Value="{x:Null}">
                      <Setter TargetName="Icon"
                                                    Property="Visibility"
                                                    Value="Collapsed"/>
                    </Trigger>
                    <Trigger Property="IsChecked"
                                                 Value="true">
                      <Setter TargetName="GlyphPanel"
                                                    Property="Visibility"
                                                    Value="Visible"/>
                      <Setter TargetName="Icon"
                                                    Property="Visibility"
                                                    Value="Collapsed"/>
                    </Trigger>
                    <Trigger Property="IsHighlighted"
                                                 Value="true">
                      <Setter TargetName="Border"
                                                    Property="BorderBrush"
                                                    Value="{StaticResource ToolBarButtonHoverBorder}"/>
                      <Setter TargetName="Border"
                                                    Property="Background"
                                                    Value="{StaticResource ToolBarButtonHover}"/>
                      <Setter TargetName="GlyphPanel"
                                                    Property="BorderBrush"
                                                    Value="{StaticResource ToolBarButtonPressedBorder}"/>
                      <Setter TargetName="GlyphPanel"
                                                    Property="Background"
                                                    Value="{StaticResource ToolBarDarkFill}"/>
                    </Trigger>
                    <Trigger SourceName="PART_Popup"
                                                  Property="Popup.HasDropShadow"
                                                  Value="true">
                      <!--Setter TargetName="Shdw"
                                                     Property="Margin"
                                                     Value="0,0,5,5"/>
                      <Setter TargetName="Shdw"
                                                     Property="SnapsToDevicePixels"
                                                     Value="true"/>
                      <Setter TargetName="Shdw"
                                                     Property="Color"
                                                     Value="#71000000"/-->
                    </Trigger>
                    <Trigger Property="IsEnabled"
                                                 Value="false">
                      <Setter Property="Foreground"
                                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                    </Trigger>
                  </ControlTemplate.Triggers>
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Trigger>
        </Style.Triggers>
      </Style>
    </Style.Resources>
  </Style>



  <Style x:Key="ToolBarThumbStyle"
           TargetType="{x:Type Thumb}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Thumb}">
          <Border Padding="{TemplateBinding Padding}"
                            Background="Transparent"
                            SnapsToDevicePixels="True">
            <Rectangle>
              <Rectangle.Fill>
                <DrawingBrush Viewbox="0,0,4,4"
                                              Viewport="0,0,4,4"
                                              TileMode="Tile"
                                              ViewportUnits="Absolute"
                                              ViewboxUnits="Absolute">
                  <DrawingBrush.Drawing>
                    <DrawingGroup>
                      <DrawingGroup.Children>
                        <!--GeometryDrawing Brush="White"
                                                                 Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/-->
                        <GeometryDrawing Brush="{StaticResource ToolBarGripper}"
                                                                 Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
                      </DrawingGroup.Children>
                    </DrawingGroup>
                  </DrawingBrush.Drawing>
                </DrawingBrush>
              </Rectangle.Fill>
            </Rectangle>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"
                                 Value="true">
              <Setter Property="Cursor"
                                    Value="SizeAll"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="ToolBarHorizontalOverflowButtonStyle"
           TargetType="{x:Type ToggleButton}">
    <Style.Triggers>
      <DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
        <Setter Property="Background" 
                        Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
      </DataTrigger>
    </Style.Triggers>
    <Setter Property="Background"
                Value="{StaticResource ToolBarToggleButtonHorizontalBackground}"/>
    <Setter Property="MinHeight"
                Value="0"/>
    <Setter Property="MinWidth"
                Value="0"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Border Name="Bd"
                            CornerRadius="0,3,3,0"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="true">
            <Canvas Width="6"
                                Height="7"
                                Margin="7,2,2,2"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Bottom"
                                SnapsToDevicePixels="true">
              <!--Path Stroke="White"
                                  Data="M 1 1.5 L 6 1.5"/-->
              <Path Stroke="{TemplateBinding Foreground}"
                                  Data="M 0 0.5 L 5 0.5"/>
              <!--Path Fill="White"
                                  Data="M 0.5 4 L 6.5 4 L 3.5 7 Z"/-->
              <Path Fill="{TemplateBinding Foreground}"
                                  Data="M -0.5 3 L 5.5 3 L 2.5 6 Z"/>
            </Canvas>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"
                                 Value="true">
              <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused"
                                 Value="true">
              <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                                 Value="false">
              <Setter Property="Foreground"
                                    Value="{StaticResource ToolBarGripper}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="ToolBarVerticalOverflowButtonStyle"
           TargetType="{x:Type ToggleButton}">
    <Style.Triggers>
      <DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
        <Setter Property="Background" 
                        Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
      </DataTrigger>
    </Style.Triggers>
    <Setter Property="Background"
                Value="{StaticResource ToolBarToggleButtonVerticalBackground}"/>
    <Setter Property="MinHeight"
                Value="0"/>
    <Setter Property="MinWidth"
                Value="0"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Border Name="Bd"
                            CornerRadius="0,0,3,3"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="true">
            <Canvas Width="7"
                                Height="6"
                                Margin="2,7,2,2"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Bottom"
                                SnapsToDevicePixels="true">
              <Path Stroke="White"
                                  Data="M 1.5 1 L 1.5 6"/>
              <Path Stroke="{TemplateBinding Foreground}"
                                  Data="M 0.5 0 L 0.5 5"/>
              <Path Fill="White"
                                  Data="M 3.5 0.5 L 7 3.5 L 4 6.5 Z"/>
              <Path Fill="{TemplateBinding Foreground}"
                                  Data="M 3 -0.5 L 6 2.5 L 3 5.5 Z"/>
            </Canvas>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"
                                 Value="true">
              <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused"
                                 Value="true">
              <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                                 Value="false">
              <Setter Property="Foreground"
                                    Value="{StaticResource ToolBarGripper}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="{x:Type ToolBar}"
           TargetType="{x:Type ToolBar}">
    <Style.Triggers>
      <DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
        <Setter Property="Background" 
                        Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
      </DataTrigger>
    </Style.Triggers>
    <Setter Property="OverridesDefaultStyle"
          Value="true" />

    <Setter Property="Background" Value="{StaticResource ToolBarHorizontalBackground}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="BorderBrush" Value="{StaticResource ToolBarBorder}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToolBar}">
          <Grid Name="Grid"
                      Margin="3,0,1,1"
                      SnapsToDevicePixels="true">
            <Grid HorizontalAlignment="Right"
                          x:Name="OverflowGrid">
              <ToggleButton x:Name="OverflowButton"
                                      FocusVisualStyle="{x:Null}"
                                      IsEnabled="{TemplateBinding HasOverflowItems}"
                                      Style="{StaticResource ToolBarHorizontalOverflowButtonStyle}"
                                      IsChecked="{Binding Path=IsOverflowOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                                      ClickMode="Press"/>
              <Popup x:Name="OverflowPopup"
                               AllowsTransparency="true"
                               Placement="Bottom"
                               IsOpen="{Binding Path=IsOverflowOpen,RelativeSource={RelativeSource TemplatedParent}}"
                               StaysOpen="false"
                               Focusable="false"
                               PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
                <!--theme:SystemDropShadowChrome Name="Shdw"
                                                          Color="Transparent"-->
                  <Border Background="{StaticResource ToolBarSubMenuBackground}"
                                        BorderBrush="{StaticResource ToolBarMenuBorder}"
                                        BorderThickness="1"
                                        RenderOptions.ClearTypeHint="Enabled"
                                        x:Name="ToolBarSubMenuBorder">
                    <ToolBarOverflowPanel x:Name="PART_ToolBarOverflowPanel"
                                                          Margin="2"
                                                          WrapWidth="200"
                                                          Focusable="true" 
                                                          FocusVisualStyle="{x:Null}"
                                                          KeyboardNavigation.TabNavigation="Cycle"
                                                          KeyboardNavigation.DirectionalNavigation="Cycle"
                                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                  </Border>
                <!--/theme:SystemDropShadowChrome-->
              </Popup>
            </Grid>
            <Border x:Name="MainPanelBorder"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            Style="{StaticResource ToolBarMainPanelBorderStyle}">
              <DockPanel KeyboardNavigation.TabIndex="1"
                                   KeyboardNavigation.TabNavigation="Local">
                <Thumb x:Name="ToolBarThumb"
                                   Style="{StaticResource ToolBarThumbStyle}"
                                   Margin="-3,-1,0,0"
                                   Width="10"
                                   Padding="6,5,1,6"/>
                <ContentPresenter x:Name="ToolBarHeader"
                                              ContentSource="Header"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              Margin="4,0,4,0"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                <ToolBarPanel x:Name="PART_ToolBarPanel"
                                          IsItemsHost="true"
                                          Margin="0,1,2,1"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
              </DockPanel>
            </Border>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsOverflowOpen"
                             Value="true">
              <Setter TargetName="ToolBarThumb"
                                Property="IsEnabled"
                                Value="false"/>
            </Trigger>
            <Trigger Property="Header"
                             Value="{x:Null}">
              <Setter TargetName="ToolBarHeader"
                                Property="Visibility"
                                Value="Collapsed"/>
            </Trigger>
            <Trigger Property="ToolBarTray.IsLocked"
                             Value="true">
              <Setter TargetName="ToolBarThumb"
                                Property="Visibility"
                                Value="Collapsed"/>
            </Trigger>
            <Trigger SourceName="OverflowPopup"
                             Property="Popup.HasDropShadow"
                             Value="true">
              <!--Setter TargetName="Shdw"
                                Property="Margin"
                                Value="0,0,5,5"/>
              <Setter TargetName="Shdw"
                                Property="SnapsToDevicePixels"
                                Value="true"/>
              <Setter TargetName="Shdw"
                                Property="Color"
                                Value="#71000000"/-->
            </Trigger>
            <Trigger Property="Orientation"
                             Value="Vertical">
              <Setter TargetName="Grid"
                                Property="Margin"
                                Value="1,3,1,1"/>
              <Setter TargetName="OverflowButton"
                                Property="Style"
                                Value="{StaticResource ToolBarVerticalOverflowButtonStyle}"/>
              <Setter TargetName="ToolBarThumb"
                                Property="Height"
                                Value="10"/>
              <Setter TargetName="ToolBarThumb"
                                Property="Width"
                                Value="Auto"/>
              <Setter TargetName="ToolBarThumb"
                                Property="Margin"
                                Value="-1,-3,0,0"/>
              <Setter TargetName="ToolBarThumb"
                                Property="Padding"
                                Value="5,6,6,1"/>
              <Setter TargetName="ToolBarHeader"
                                Property="Margin"
                                Value="0,0,0,4"/>
              <Setter TargetName="PART_ToolBarPanel"
                                Property="Margin"
                                Value="1,0,2,2"/>
              <Setter TargetName="ToolBarThumb"
                                Property="DockPanel.Dock"
                                Value="Top"/>
              <Setter TargetName="ToolBarHeader"
                                Property="DockPanel.Dock"
                                Value="Top"/>
              <Setter TargetName="OverflowGrid"
                                Property="HorizontalAlignment"
                                Value="Stretch"/>
              <Setter TargetName="OverflowGrid"
                                Property="VerticalAlignment"
                                Value="Bottom"/>
              <Setter TargetName="OverflowPopup"
                                Property="Placement"
                                Value="Right"/>
              <Setter TargetName="MainPanelBorder"
                                Property="Margin"
                                Value="0,0,0,11"/>
              <Setter Property="Background"
                                Value="{StaticResource ToolBarVerticalBackground}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                             Value="false">
              <Setter Property="Foreground"
                                Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="SimpleToolBarStyle"
           TargetType="{x:Type ToolBar}">
    <Style.Triggers>
      <DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
        <Setter Property="Background" 
                        Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
      </DataTrigger>
    </Style.Triggers>
    <Setter Property="OverridesDefaultStyle"
          Value="true" />

    <Setter Property="Background" Value="{StaticResource ToolBarHorizontalBackground}"/>
    <Setter Property="BorderThickness" Value="0"/>
    <!--Setter Property="BorderBrush" Value="{StaticResource ToolBarBorder}"/-->
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToolBar}">
          <Grid Name="Grid"
                      Margin="0,0,0,0"
                      SnapsToDevicePixels="true">
            <!--Grid HorizontalAlignment="Right"
                          x:Name="OverflowGrid">
              <ToggleButton x:Name="OverflowButton"
                                      FocusVisualStyle="{x:Null}"
                                      IsEnabled="{TemplateBinding HasOverflowItems}"
                                      Style="{StaticResource ToolBarHorizontalOverflowButtonStyle}"
                                      IsChecked="{Binding Path=IsOverflowOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                                      ClickMode="Press"/>
              <Popup x:Name="OverflowPopup"
                               AllowsTransparency="true"
                               Placement="Bottom"
                               IsOpen="{Binding Path=IsOverflowOpen,RelativeSource={RelativeSource TemplatedParent}}"
                               StaysOpen="false"
                               Focusable="false"
                               PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
                <Border Background="{StaticResource ToolBarSubMenuBackground}"
                                        BorderBrush="{StaticResource ToolBarMenuBorder}"
                                        BorderThickness="1"
                                        RenderOptions.ClearTypeHint="Enabled"
                                        x:Name="ToolBarSubMenuBorder">
                  <ToolBarOverflowPanel x:Name="PART_ToolBarOverflowPanel"
                                                          Margin="2"
                                                          WrapWidth="200"
                                                          Focusable="true" 
                                                          FocusVisualStyle="{x:Null}"
                                                          KeyboardNavigation.TabNavigation="Cycle"
                                                          KeyboardNavigation.DirectionalNavigation="Cycle"
                                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                </Border>
              </Popup>
            </Grid-->
            <Border x:Name="MainPanelBorder"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}">
                            <!--Style="{StaticResource ToolBarMainPanelBorderStyle}"-->
              <DockPanel KeyboardNavigation.TabIndex="1"
                                   KeyboardNavigation.TabNavigation="Local">
                <!--Thumb x:Name="ToolBarThumb"
                                   Style="{StaticResource ToolBarThumbStyle}"
                                   Margin="-3,-1,0,0"
                                   Width="10"
                                   Padding="6,5,1,6"/-->
                <ContentPresenter x:Name="ToolBarHeader"
                                              ContentSource="Header"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              Margin="4,0,4,0"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                <ToolBarPanel x:Name="PART_ToolBarPanel"
                                          IsItemsHost="true"
                                          Margin="0,1,2,1"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
              </DockPanel>
            </Border>
          </Grid>
          <ControlTemplate.Triggers>
            <!--Trigger Property="IsOverflowOpen"
                             Value="true">
              <Setter TargetName="ToolBarThumb"
                                Property="IsEnabled"
                                Value="false"/>
            </Trigger-->
            <Trigger Property="Header"
                             Value="{x:Null}">
              <Setter TargetName="ToolBarHeader"
                                Property="Visibility"
                                Value="Collapsed"/>
            </Trigger>
            <!--Trigger Property="ToolBarTray.IsLocked"
                             Value="true">
              <Setter TargetName="ToolBarThumb"
                                Property="Visibility"
                                Value="Collapsed"/>
            </Trigger-->
            <Trigger Property="Orientation"
                             Value="Vertical">
              <Setter TargetName="Grid"
                                Property="Margin"
                                Value="1,3,1,1"/>
              <!--Setter TargetName="OverflowButton"
                                Property="Style"
                                Value="{StaticResource ToolBarVerticalOverflowButtonStyle}"/-->
              <!--Setter TargetName="ToolBarThumb"
                                Property="Height"
                                Value="10"/>
              <Setter TargetName="ToolBarThumb"
                                Property="Width"
                                Value="Auto"/>
              <Setter TargetName="ToolBarThumb"
                                Property="Margin"
                                Value="-1,-3,0,0"/>
              <Setter TargetName="ToolBarThumb"
                                Property="Padding"
                                Value="5,6,6,1"/-->
              <Setter TargetName="ToolBarHeader"
                                Property="Margin"
                                Value="0,0,0,4"/>
              <Setter TargetName="PART_ToolBarPanel"
                                Property="Margin"
                                Value="1,0,2,2"/>
              <!--Setter TargetName="ToolBarThumb"
                                Property="DockPanel.Dock"
                                Value="Top"/-->
              <Setter TargetName="ToolBarHeader"
                                Property="DockPanel.Dock"
                                Value="Top"/>
              <!--Setter TargetName="OverflowGrid"
                                Property="HorizontalAlignment"
                                Value="Stretch"/>
              <Setter TargetName="OverflowGrid"
                                Property="VerticalAlignment"
                                Value="Bottom"/>
              <Setter TargetName="OverflowPopup"
                                Property="Placement"
                                Value="Right"/-->
              <Setter TargetName="MainPanelBorder"
                                Property="Margin"
                                Value="0,0,0,11"/>
              <Setter Property="Background"
                                Value="{StaticResource ToolBarVerticalBackground}"/>
            </Trigger>
            <Trigger Property="IsEnabled"
                             Value="false">
              <Setter Property="Foreground"
                                Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="{x:Type ToolBarTray}" TargetType="{x:Type ToolBarTray}">
    <Setter Property="Background" 
                Value="{StaticResource ToolBarTrayBackground}"/>
    <Style.Triggers>
      <DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
        <Setter Property="Background" 
                        Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
      </DataTrigger>
    </Style.Triggers>
  </Style>

  <Style TargetType="{x:Type Image}"  x:Key="ToolBarButtonImageStyle">
    <Setter Property="Width" Value="16" />
    <Setter Property="Height" Value="16" />
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, Mode=FindAncestor}, Path=IsEnabled}" Value="False">
        <Setter Property="Opacity" Value="0.30" />
      </DataTrigger>
    </Style.Triggers>
  </Style>






  <!-- Menu / MenuItem -->

  <!--LinearGradientBrush x:Key="MenuBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#F6F6F6"
                          Offset="0.25"/>
      <GradientStop Color="#EAE8E8"
                          Offset="0.25"/>
      <GradientStop Color="#DCD9D9"
                          Offset="0.8"/>
      <GradientStop Color="White"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush-->
  <LinearGradientBrush x:Key="MenuBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#CAD3E2"
                          Offset="0"/>
      <GradientStop Color="#AEB9CD"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush>

  <Style x:Key="{x:Type Menu}"
           TargetType="{x:Type Menu}">
    <Setter Property="Background"
                Value="{StaticResource MenuBackground}"/>
    <Setter Property="FontFamily"
                Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}"/>
    <Setter Property="FontSize"
                Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}"/>
    <Setter Property="FontStyle"
                Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}"/>
    <Setter Property="FontWeight"
                Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}"/>
    <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Menu}">
          <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="true">
            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>


  <MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter"/>
  <Geometry x:Key="DownArrow">M 0,0 L 3.5,4 L 7,0 Z</Geometry>
  <Geometry x:Key="UpArrow">M 0,4 L 3.5,0 L 7,4 Z</Geometry>
  <Geometry x:Key="RightArrow">M 0,0 L 4,3.5 L 0,7 Z</Geometry>

  <Geometry x:Key="Checkmark">M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z</Geometry>


  <!--SolidColorBrush x:Key="SubMenuBackgroundBrush" Color="#FFF5F5F5" /-->
  <LinearGradientBrush x:Key="SubMenuBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
    <GradientStop Offset="0" Color="#E9ECEE"/>
    <GradientStop Offset="1" Color="#D0D7E2"/>
  </LinearGradientBrush>
  
  <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=SubmenuContent}"
                     TargetType="{x:Type ContentControl}">
    <!--Border Background="{StaticResource SubMenuBackgroundBrush}"
                BorderBrush="#FF959595"
                BorderThickness="1">
      <Grid>
        <Rectangle Fill="#F1F1F1"
                           HorizontalAlignment="Left"
                           Width="28"
                           Margin="2"
                           RadiusX="2"
                           RadiusY="2"/>
        <Rectangle HorizontalAlignment="Left"
                           Width="1"
                           Margin="30,2,0,2"
                           Fill="#E2E3E3"/>
        <Rectangle HorizontalAlignment="Left"
                           Width="1"
                           Margin="31,2,0,2"
                           Fill="White"/>
        <ContentPresenter Grid.ColumnSpan="2" Margin="1,0"/>
      </Grid>
    </Border-->
    <Border 
                BorderBrush="#9BA7B7"
                BorderThickness="1">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="27"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Rectangle Grid.Column="0" Fill="#E9ECEE"/>
        <Rectangle Grid.Column="1" Fill="{StaticResource SubMenuBackgroundBrush}"/>
        <!--Rectangle Fill="#F1F1F1"
                           HorizontalAlignment="Left"
                           Width="28"
                           Margin="2"
                           RadiusX="2"
                           RadiusY="2"/>
        <Rectangle HorizontalAlignment="Left"
                           Width="1"
                           Margin="30,2,0,2"
                           Fill="#E2E3E3"/>
        <Rectangle HorizontalAlignment="Left"
                           Width="1"
                           Margin="31,2,0,2"
                           Fill="White"/-->
        <ContentPresenter Grid.ColumnSpan="2" Margin="1,0"/>
      </Grid>
    </Border>
  </ControlTemplate>
  
  <Style x:Key="MenuScrollButton"
           TargetType="{x:Type RepeatButton}"
           BasedOn="{x:Null}">
    <Setter Property="ClickMode"
                Value="Hover"/>
    <Setter Property="MinWidth"
                Value="0"/>
    <Setter Property="MinHeight"
                Value="0"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RepeatButton}">
          <DockPanel Background="Transparent"
                               SnapsToDevicePixels="true">
            <Rectangle DockPanel.Dock="Right"
                                   x:Name="R1"
                                   Width="1"
                                   Fill="Transparent"/>
            <Rectangle DockPanel.Dock="Bottom"
                                   x:Name="B1"
                                   Height="1"
                                   Fill="Transparent"/>
            <Rectangle DockPanel.Dock="Left"
                                   x:Name="L1"
                                   Width="1"
                                   Fill="Transparent"/>
            <Rectangle DockPanel.Dock="Top"
                                   x:Name="T1"
                                   Height="1"
                                   Fill="Transparent"/>
            <ContentPresenter x:Name="ContentContainer"
                                          Margin="2,2,2,2"
                                          VerticalAlignment="Center"
                                          HorizontalAlignment="Center"/>
          </DockPanel>
          <ControlTemplate.Triggers>
            <Trigger Property="IsPressed"
                                 Value="true">
              <Setter TargetName="R1"
                                    Property="Fill"
                                    Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/>
              <Setter TargetName="B1"
                                    Property="Fill"
                                    Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/>
              <Setter TargetName="L1"
                                    Property="Fill"
                                    Value="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"/>
              <Setter TargetName="T1"
                                    Property="Fill"
                                    Value="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"/>
              <Setter TargetName="ContentContainer"
                                    Property="Margin"
                                    Value="3,3,1,1"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>


  <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}"
           TargetType="{x:Type ScrollViewer}"
           BasedOn="{x:Null}">
    <Setter Property="HorizontalScrollBarVisibility"
                Value="Hidden"/>
    <Setter Property="VerticalScrollBarVisibility"
                Value="Auto"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ScrollViewer}">
          <Grid SnapsToDevicePixels="true">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto"/>
              <RowDefinition Height="*"/>
              <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Border Grid.Row="1"
                                Grid.Column="0">
              <ScrollContentPresenter Margin="{TemplateBinding Padding}"/>
            </Border>
            <RepeatButton
                                      Style="{StaticResource MenuScrollButton}"
                                      Grid.Row="0"
                                      Grid.Column="0"
                                      Command="{x:Static ScrollBar.LineUpCommand}"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      Focusable="false">
              <RepeatButton.Visibility>
                <MultiBinding FallbackValue="Visibility.Collapsed"
                                              Converter="{StaticResource MenuScrollingVisibilityConverter}"
                                              ConverterParameter="0">
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                             Path="ComputedVerticalScrollBarVisibility"/>
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                             Path="VerticalOffset"/>
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                             Path="ExtentHeight"/>
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                             Path="ViewportHeight"/>
                </MultiBinding>
              </RepeatButton.Visibility>
              <Path Fill="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"
                                  Data="{StaticResource UpArrow}"/>
            </RepeatButton>
            <RepeatButton
                                      Style="{StaticResource MenuScrollButton}"
                                      Grid.Row="2"
                                      Grid.Column="0"
                                      Command="{x:Static ScrollBar.LineDownCommand}"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      Focusable="false">
              <RepeatButton.Visibility>
                <MultiBinding FallbackValue="Visibility.Collapsed"
                                              Converter="{StaticResource MenuScrollingVisibilityConverter}"
                                              ConverterParameter="100">
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                             Path="ComputedVerticalScrollBarVisibility"/>
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                             Path="VerticalOffset"/>
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                             Path="ExtentHeight"/>
                  <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                             Path="ViewportHeight"/>
                </MultiBinding>
              </RepeatButton.Visibility>
              <Path Fill="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"
                                  Data="{StaticResource DownArrow}"/>
            </RepeatButton>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>




  <SolidColorBrush x:Key="MenuItemBorder" Color="#E5C365"/>

  <!--LinearGradientBrush x:Key="MenuItemSelectionFill"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#34C5EBFF"
                          Offset="0"/>
      <GradientStop Color="#3481D8FF"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush-->
  <LinearGradientBrush x:Key="MenuItemSelectionFill"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#FFFCF2"
                          Offset="0"/>
      <GradientStop Color="#FFF3CF"
                          Offset="0.5"/>
      <GradientStop Color="#FFECB5"
                          Offset="0.5"/>
      <GradientStop Color="#FFECB5"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush>
  
  <!--LinearGradientBrush x:Key="MenuItemPressedFill"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#28717070"
                          Offset="0"/>
      <GradientStop Color="#50717070"
                          Offset="0.75"/>
      <GradientStop Color="#90717070"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush-->
  <LinearGradientBrush x:Key="MenuItemPressedFill"
                         StartPoint="0,0"
                         EndPoint="0,1">
    <LinearGradientBrush.GradientStops>
      <GradientStop Color="#FFFCF2"
                          Offset="0"/>
      <GradientStop Color="#FFF3CF"
                          Offset="0.5"/>
      <GradientStop Color="#FFECB5"
                          Offset="0.5"/>
      <GradientStop Color="#FFECB5"
                          Offset="1"/>
    </LinearGradientBrush.GradientStops>
  </LinearGradientBrush>
  
  <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}"
           TargetType="{x:Type Separator}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Separator}">
          <Grid SnapsToDevicePixels="true" Margin="0,6,0,4">
            <Rectangle Height="1"
                                   Margin="30,0,1,1"
                                   Fill="#BEC3CB"/>
            <!--Rectangle Height="1"
                                   Margin="30,0,1,1"
                                   Fill="#E0E0E0"/>
            <Rectangle Height="1"
                                   Margin="30,1,1,0"
                                   Fill="White"/-->
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelItemTemplateKey}"
                     TargetType="{x:Type MenuItem}">
    <Grid SnapsToDevicePixels="true">
      <Rectangle x:Name="OuterBorder"
                       RadiusX="2"
                       RadiusY="2"/>
      <Rectangle Name="Bg"
                       Margin="1"
                       Fill="{TemplateBinding MenuItem.Background}"
                       Stroke="{TemplateBinding MenuItem.BorderBrush}"
                       StrokeThickness="1"
                       RadiusX="1"
                       RadiusY="1"/>
      <Rectangle x:Name="InnerBorder"
                       Margin="2"/>
      <DockPanel>
        <ContentPresenter x:Name="Icon"
                                  Margin="4,0,6,0"
                                  VerticalAlignment="Center"
                                  ContentSource="Icon"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        <Path x:Name="GlyphPanel"
                      Margin="7,0,0,0"
                      Visibility="Collapsed"
                      VerticalAlignment="Center"
                      Fill="{TemplateBinding MenuItem.Foreground}"
                      FlowDirection="LeftToRight"
                      Data="{StaticResource Checkmark}"/>
        <ContentPresenter ContentSource="Header"
                                  Margin="{TemplateBinding MenuItem.Padding}"
                                  RecognizesAccessKey="True"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
      </DockPanel>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="Icon"
                     Value="{x:Null}">
        <Setter TargetName="Icon"
                        Property="Visibility"
                        Value="Collapsed"/>
      </Trigger>
      <Trigger Property="IsChecked"
                     Value="true">
        <Setter TargetName="GlyphPanel"
                        Property="Visibility"
                        Value="Visible"/>
        <Setter TargetName="Icon"
                        Property="Visibility"
                        Value="Collapsed"/>
      </Trigger>
      <Trigger Property="IsHighlighted"
                     Value="true">
        <Setter TargetName="Bg"
                        Property="Stroke"
                        Value="#90717070"/>
        <Setter TargetName="OuterBorder"
                        Property="Stroke"
                        Value="#50FFFFFF"/>
        <Setter TargetName="InnerBorder"
                        Property="Stroke"
                        Value="#50FFFFFF"/>

      </Trigger>

      <Trigger Property="IsKeyboardFocused"
                     Value="true">
        <Setter TargetName="Bg"
                        Property="Stroke"
                        Value="#E0717070"/>
        <Setter TargetName="Bg"
                        Property="Fill"
                        Value="{StaticResource MenuItemPressedFill}"/>
        <Setter TargetName="InnerBorder"
                        Property="Stroke"
                        Value="#50747272"/>
      </Trigger>
      <Trigger Property="IsEnabled"
                     Value="false">
        <Setter Property="Foreground"
                        Value="#FF9A9A9A"/>
        <Setter TargetName="GlyphPanel"
                        Property="Fill"
                        Value="#848589"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelHeaderTemplateKey}"
                     TargetType="{x:Type MenuItem}">
    <Grid SnapsToDevicePixels="true">
      <Rectangle x:Name="OuterBorder"
                       RadiusX="2"
                       RadiusY="2"/>
      <Rectangle Name="Bg"
                       Margin="1"
                       Fill="{TemplateBinding MenuItem.Background}"
                       Stroke="{TemplateBinding MenuItem.BorderBrush}"
                       StrokeThickness="1"
                       RadiusX="1"
                       RadiusY="1"/>
      <Rectangle x:Name="InnerBorder"
                       Margin="2"/>
      <DockPanel>
        <ContentPresenter x:Name="Icon"
                                  Margin="4,0,6,0"
                                  VerticalAlignment="Center"
                                  ContentSource="Icon"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        <Path x:Name="GlyphPanel"
                      Margin="7,0,0,0"
                      Visibility="Collapsed"
                      VerticalAlignment="Center"
                      Fill="{TemplateBinding MenuItem.Foreground}"
                      FlowDirection="LeftToRight"
                      Data="{StaticResource Checkmark}"/>
        <ContentPresenter ContentSource="Header"
                                  Margin="{TemplateBinding MenuItem.Padding}"
                                  RecognizesAccessKey="True"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
      </DockPanel>
      <Popup x:Name="PART_Popup"
                   HorizontalOffset="1"
                   VerticalOffset="-1"
                   AllowsTransparency="true"
                   Placement="Bottom"
                   IsOpen="{Binding Path=IsSubmenuOpen,RelativeSource={RelativeSource TemplatedParent}}"
                   Focusable="false"
                   PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
        <!--theme:SystemDropShadowChrome Name="Shdw"
                                              Color="Transparent"-->
        <ContentControl Name="SubMenuBorder"
                                  Template="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=SubmenuContent}}"
                                  IsTabStop="false">
          <ScrollViewer Name="SubMenuScrollViewer" CanContentScroll="true"
                                    Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
            <Grid RenderOptions.ClearTypeHint="Enabled">
              <!--Canvas Height="0" Width="0" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Rectangle
                                  Height="{Binding ElementName=SubMenuBorder,Path=ActualHeight}" 
                                  Width="{Binding ElementName=SubMenuBorder,Path=ActualWidth}" 
                                  Fill="{StaticResource SubMenuBackgroundBrush}" />
              </Canvas-->

              <Canvas Height="0" Width="0" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Rectangle Fill="#E9ECEE"
                           Width="27"
                           Height="{Binding ElementName=SubMenuBorder,Path=ActualHeight}"/>
                <Rectangle Canvas.Left="28"
                                  Height="{Binding ElementName=SubMenuBorder,Path=ActualHeight}" 
                                  Width="{Binding ElementName=SubMenuBorder,Path=ActualWidth}" 
                                  Fill="{StaticResource SubMenuBackgroundBrush}" />
              </Canvas>
                
              <ItemsPresenter Name="ItemsPresenter" Margin="2" 
                                            KeyboardNavigation.TabNavigation="Cycle"
                                            KeyboardNavigation.DirectionalNavigation="Cycle"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                            Grid.IsSharedSizeScope="true"/>
              </Grid>
            </ScrollViewer>
          </ContentControl>
        <!--/theme:SystemDropShadowChrome-->
      </Popup>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="IsSuspendingPopupAnimation"
                     Value="true">
        <Setter TargetName="PART_Popup"
                        Property="PopupAnimation"
                        Value="None"/>
      </Trigger>
      <Trigger Property="Icon"
                     Value="{x:Null}">
        <Setter TargetName="Icon"
                        Property="Visibility"
                        Value="Collapsed"/>
      </Trigger>
      <Trigger Property="IsChecked"
                     Value="true">
        <Setter TargetName="GlyphPanel"
                        Property="Visibility"
                        Value="Visible"/>
        <Setter TargetName="Icon"
                        Property="Visibility"
                        Value="Collapsed"/>
      </Trigger>
      <Trigger SourceName="PART_Popup"
                     Property="Popup.HasDropShadow"
                     Value="true">
        <!--Setter TargetName="Shdw"
                        Property="Margin"
                        Value="0,0,5,5"/>
        <Setter TargetName="Shdw"
                        Property="Color"
                        Value="#71000000"/-->
      </Trigger>
      <!--Trigger Property="IsHighlighted"
                     Value="true">
        <Setter TargetName="Bg"
                        Property="Stroke"
                        Value="#90717070"/>
        <Setter TargetName="OuterBorder"
                        Property="Stroke"
                        Value="#50FFFFFF"/>
        <Setter TargetName="InnerBorder"
                        Property="Stroke"
                        Value="#50FFFFFF"/>

      </Trigger-->
      <Trigger Property="IsHighlighted"
                     Value="true">
        <Setter TargetName="Bg"
                        Property="Fill"
                        Value="{StaticResource MenuItemSelectionFill}"/>
        <Setter TargetName="OuterBorder"
                        Property="Stroke"
                        Value="{StaticResource MenuItemBorder}"/>
        <Setter TargetName="InnerBorder"
                        Property="Stroke"
                        Value="Transparent"/>
      </Trigger>
      <Trigger Property="IsKeyboardFocused"
                     Value="true">
        <Setter TargetName="Bg"
                        Property="Stroke"
                        Value="#E0717070"/>
        <Setter TargetName="Bg"
                        Property="Fill"
                        Value="{StaticResource MenuItemPressedFill}"/>
        <Setter TargetName="InnerBorder"
                        Property="Stroke"
                        Value="#50747272"/>
      </Trigger>
      <!--Trigger Property="IsSubmenuOpen"
                     Value="true">
        <Setter TargetName="Bg"
                        Property="Stroke"
                        Value="#E0717070"/>
        <Setter TargetName="Bg"
                        Property="Fill"
                        Value="{StaticResource MenuItemPressedFill}"/>
        <Setter TargetName="InnerBorder"
                        Property="Stroke"
                        Value="#50747272"/>
      </Trigger-->
      <Trigger Property="IsSubmenuOpen"
                     Value="true">
        <Setter TargetName="Bg"
                        Property="Stroke"
                        Value="#9BA7B7"/>
        <Setter TargetName="Bg"
                        Property="Fill"
                        Value="#E9ECEE"/>
        <Setter TargetName="InnerBorder"
                        Property="Stroke"
                        Value="Transparent"/>
      </Trigger>
      <Trigger Property="IsEnabled"
                     Value="false">
        <Setter Property="Foreground"
                        Value="#FF9A9A9A"/>
        <Setter TargetName="GlyphPanel"
                        Property="Fill"
                        Value="#848589"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuItemTemplateKey}"
                     TargetType="{x:Type MenuItem}">
    <Grid SnapsToDevicePixels="true">
      <Rectangle Name="Bg"
                       Fill="{TemplateBinding MenuItem.Background}"
                       Stroke="{TemplateBinding MenuItem.BorderBrush}"
                       StrokeThickness="1"
                       RadiusX="2"
                       RadiusY="2"/>
      <Rectangle x:Name="InnerBorder"
                       Margin="1"
                       RadiusX="2"
                       RadiusY="2"/>
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition MinWidth="24"
                                      Width="Auto"
                                      SharedSizeGroup="MenuItemIconColumnGroup"/>
          <ColumnDefinition Width="4"/>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="37"/>
          <ColumnDefinition Width="Auto"
                                      SharedSizeGroup="MenuItemIGTColumnGroup"/>
          <ColumnDefinition Width="17"/>
        </Grid.ColumnDefinitions>
        <ContentPresenter x:Name="Icon"
                                  Margin="1"
                                  VerticalAlignment="Center"
                                  ContentSource="Icon"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

        <!--                        Background="#E6EFF4"
                        BorderBrush="#CDD3E6"
-->
        <Border x:Name="GlyphPanel"
                        Background="{StaticResource ToolBarButtonPressed}"
                        BorderBrush="{StaticResource MenuItemBorder}"
                        BorderThickness="1"
                        CornerRadius="3"
                        Margin="1"
                        Visibility="Hidden"
                        Width="22" 
                        Height="22">
          <Path Name="Glyph"
                          Width="9"
                          Height="11"
                          Fill="#0C12A1"
                          FlowDirection="LeftToRight"
                          Data="{StaticResource Checkmark}"/>
        </Border>
        <ContentPresenter Grid.Column="2"
                                  ContentSource="Header"
                                  Margin="{TemplateBinding MenuItem.Padding}"
                                  RecognizesAccessKey="True"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        <TextBlock Grid.Column="4"
                           Text="{TemplateBinding MenuItem.InputGestureText}"
                           Margin="{TemplateBinding MenuItem.Padding}"/>
      </Grid>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="Icon"
                     Value="{x:Null}">
        <Setter TargetName="Icon"
                        Property="Visibility"
                        Value="Collapsed"/>
      </Trigger>
      <Trigger Property="IsChecked"
                     Value="true">
        <Setter TargetName="GlyphPanel"
                        Property="Visibility"
                        Value="Visible"/>
        <Setter TargetName="Icon"
                        Property="Visibility"
                        Value="Collapsed"/>
      </Trigger>
      <Trigger Property="IsHighlighted"
                     Value="true">
        <Setter TargetName="Bg"
                        Property="Fill"
                        Value="{StaticResource MenuItemSelectionFill}"/>
        <Setter TargetName="Bg"
                        Property="Stroke"
                        Value="#8071CBF1"/>
        <Setter TargetName="InnerBorder"
                        Property="Stroke"
                Value="{StaticResource MenuItemBorder}"/>
                        <!--Value="#40FFFFFF"/-->
      </Trigger>
      <Trigger Property="IsEnabled"
                     Value="false">
        <Setter Property="Foreground"
                        Value="#FF9A9A9A"/>
        <Setter TargetName="GlyphPanel"
                        Property="Background"
                        Value="#EEE9E9"/>
        <Setter TargetName="GlyphPanel"
                        Property="BorderBrush"
                        Value="#DBD6D6"/>
        <Setter TargetName="Glyph"
                        Property="Fill"
                        Value="#848589"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuHeaderTemplateKey}"
                     TargetType="{x:Type MenuItem}">
    <Grid SnapsToDevicePixels="true">
      <Rectangle Name="Bg"
                       Fill="{TemplateBinding MenuItem.Background}"
                       Stroke="{TemplateBinding MenuItem.BorderBrush}"
                       StrokeThickness="1"
                       RadiusX="2"
                       RadiusY="2"/>
      <Rectangle x:Name="InnerBorder"
                       Margin="1"
                       Stroke="Transparent"
                       StrokeThickness="1"
                       RadiusX="2"
                       RadiusY="2"/>
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition MinWidth="24"
                                      Width="Auto"
                                      SharedSizeGroup="MenuItemIconColumnGroup"/>
          <ColumnDefinition Width="4"/>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="37"/>
          <ColumnDefinition Width="Auto"
                                      SharedSizeGroup="MenuItemIGTColumnGroup"/>
          <ColumnDefinition Width="17"/>
        </Grid.ColumnDefinitions>
        <ContentPresenter x:Name="Icon"
                                  Margin="1"
                                  VerticalAlignment="Center"
                                  ContentSource="Icon"
                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
<!--                        Background="#E6EFF4"
                        BorderBrush="#CDD3E6"

        -->
        <Border x:Name="GlyphPanel"
                        Background="{StaticResource ToolBarButtonPressed}"
                        BorderBrush="{StaticResource MenuItemBorder}"
                        BorderThickness="1"
                        CornerRadius="3"
                        Margin="1"
                        Visibility="Hidden"
                        Width="22" 
                        Height="22">
          <Path Name="Glyph"
                          Width="9"
                          Height="11"
                          Fill="#0C12A1"
                          FlowDirection="LeftToRight"
                          Data="{StaticResource Checkmark}"/>
        </Border>
        <ContentPresenter Grid.Column="2"
                                  ContentSource="Header"
                                  Margin="{TemplateBinding MenuItem.Padding}"
                                  RecognizesAccessKey="True"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        <TextBlock Grid.Column="4"
                           Text="{TemplateBinding MenuItem.InputGestureText}"
                           Margin="{TemplateBinding MenuItem.Padding}"
                           Visibility="Collapsed"/>
        <Path Grid.Column="5"
                      VerticalAlignment="Center"
                      Margin="4,0,0,0"
                      Fill="{TemplateBinding MenuItem.Foreground}"
                      Data="{StaticResource RightArrow}"/>
      </Grid>
      <Popup x:Name="PART_Popup"
                   AllowsTransparency="true"
                   Placement="Right"
                   VerticalOffset="-3"
                   HorizontalOffset="-2"
                   IsOpen="{Binding Path=IsSubmenuOpen,RelativeSource={RelativeSource TemplatedParent}}"
                   Focusable="false"
                   PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
        <!--theme:SystemDropShadowChrome Name="Shdw"
                                              Color="Transparent"-->
          <ContentControl Name="SubMenuBorder"
                                    Template="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=SubmenuContent}}"
                                    IsTabStop="false">
            <ScrollViewer Name="SubMenuScrollViewer" CanContentScroll="true"
                                      Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
              <Grid RenderOptions.ClearTypeHint="Enabled">
                <!--Canvas Height="0" Width="0" HorizontalAlignment="Left" VerticalAlignment="Top">
                  <Rectangle
                                    Height="{Binding ElementName=SubMenuBorder,Path=ActualHeight}" 
                                    Width="{Binding ElementName=SubMenuBorder,Path=ActualWidth}" 
                                    Fill="{StaticResource SubMenuBackgroundBrush}" />
                </Canvas-->
              <Canvas Height="0" Width="0" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Rectangle Fill="#E9ECEE"
                           Width="27"
                           Height="{Binding ElementName=SubMenuBorder,Path=ActualHeight}"/>
                <Rectangle Canvas.Left="28"
                                  Height="{Binding ElementName=SubMenuBorder,Path=ActualHeight}" 
                                  Width="{Binding ElementName=SubMenuBorder,Path=ActualWidth}" 
                                  Fill="{StaticResource SubMenuBackgroundBrush}" />
              </Canvas>
              <ItemsPresenter Name="ItemsPresenter" Margin="2"
                                            KeyboardNavigation.TabNavigation="Cycle"
                                            KeyboardNavigation.DirectionalNavigation="Cycle"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                            Grid.IsSharedSizeScope="true"/>
              </Grid>
            </ScrollViewer>
          </ContentControl>
        <!--/theme:SystemDropShadowChrome-->
      </Popup>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="IsSuspendingPopupAnimation"
                     Value="true">
        <Setter TargetName="PART_Popup"
                        Property="PopupAnimation"
                        Value="None"/>
      </Trigger>
      <Trigger Property="IsHighlighted"
                     Value="true">
        <Setter TargetName="InnerBorder"
                        Property="Stroke"
                        Value="#D1DBF4FF"/>
      </Trigger>
      <Trigger Property="Icon"
                     Value="{x:Null}">
        <Setter TargetName="Icon"
                        Property="Visibility"
                        Value="Collapsed"/>
      </Trigger>
      <Trigger Property="IsChecked"
                     Value="true">
        <Setter TargetName="GlyphPanel"
                        Property="Visibility"
                        Value="Visible"/>
        <Setter TargetName="Icon"
                        Property="Visibility"
                        Value="Collapsed"/>
      </Trigger>
      <Trigger SourceName="PART_Popup"
                     Property="Popup.HasDropShadow"
                     Value="true">
        <!--Setter TargetName="Shdw"
                        Property="Margin"
                        Value="0,0,5,5"/>
        <Setter TargetName="Shdw"
                        Property="Color"
                        Value="#71000000"/-->
      </Trigger>
      <Trigger Property="IsHighlighted"
                     Value="true">
        <Setter TargetName="Bg"
                        Property="Fill"
                        Value="{StaticResource MenuItemSelectionFill}"/>
        <Setter TargetName="Bg"
                        Property="Stroke"
                Value="{StaticResource MenuItemBorder}"/>
                        <!--Value="#8571CBF1"/-->
      </Trigger>
      <Trigger Property="IsEnabled"
                     Value="false">
        <Setter Property="Foreground"
                        Value="#FF9A9A9A"/>
        <Setter TargetName="GlyphPanel"
                        Property="Background"
                        Value="#EEE9E9"/>
        <Setter TargetName="GlyphPanel"
                        Property="BorderBrush"
                        Value="#DBD6D6"/>
        <Setter TargetName="Glyph"
                        Property="Fill"
                        Value="#848589"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="{x:Type MenuItem}"
           TargetType="{x:Type MenuItem}">
    <Setter Property="HorizontalContentAlignment"
                Value="{Binding Path=HorizontalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
    <Setter Property="VerticalContentAlignment"
                Value="{Binding Path=VerticalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
    <Setter Property="Background"
                Value="Transparent"/>
    <Setter Property="ScrollViewer.PanningMode"
                Value="Both"/>
    <Setter Property="Stylus.IsFlicksEnabled"
                Value="False"/>
    <Setter Property="Template"
                Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuItemTemplateKey}}"/>
    <Style.Triggers>
      <Trigger Property="Role"
                     Value="TopLevelHeader">
        <Setter Property="Padding"
                        Value="7,2,8,3"/>
        <Setter Property="Template"
                        Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelHeaderTemplateKey}}"/>
      </Trigger>
      <Trigger Property="Role"
                     Value="TopLevelItem">
        <Setter Property="Padding"
                        Value="7,2,8,3"/>
        <Setter Property="Template"
                        Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelItemTemplateKey}}"/>
      </Trigger>
      <Trigger Property="Role"
                     Value="SubmenuHeader">
        <Setter Property="Padding"
                        Value="2,3,2,3"/>
        <Setter Property="Template"
                        Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuHeaderTemplateKey}}"/>
      </Trigger>
      <Trigger Property="Role"
                     Value="SubmenuItem">
        <Setter Property="Padding"
                        Value="2,3,2,3"/>
      </Trigger>
    </Style.Triggers>
  </Style>

  <Style TargetType="{x:Type Image}" x:Key="MenuItemImageStyle">
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}, Path=IsEnabled}" Value="False">
        <Setter Property="Opacity" Value="0.30" />
      </DataTrigger>
    </Style.Triggers>
    <Setter Property="Width" Value="32" />
    <Setter Property="Height" Value="32" />
  </Style>





</ResourceDictionary>